// Copyright (c) 2024 CHANGLEI. All rights reserved.

import 'package:charts_grasp/src/circular_chart/utils/enum.dart';
import 'package:charts_grasp/src/common/utils/enum.dart';
import 'package:flutter/material.dart';

class CircularChartAnnotation {
  CircularChartAnnotation({
    int? angle,
    String? radius,
    this.widget,
    String? height,
    String? width,
    ChartAlignment? horizontalAlignment,
    ChartAlignment? verticalAlignment,
  })  : angle = angle ?? 0,
        radius = radius ?? '0%',
        height = height ?? '0%',
        width = width ?? '0%',
        verticalAlignment = verticalAlignment ?? ChartAlignment.center,
        horizontalAlignment = horizontalAlignment ?? ChartAlignment.center;

  final int angle;

  final String radius;

  final Widget? widget;

  final String height;

  final String width;

  final ChartAlignment horizontalAlignment;

  final ChartAlignment verticalAlignment;

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) {
      return true;
    }
    if (other.runtimeType != runtimeType) {
      return false;
    }

    return other is CircularChartAnnotation &&
        other.angle == angle &&
        other.radius == radius &&
        other.height == height &&
        other.horizontalAlignment == horizontalAlignment &&
        other.verticalAlignment == verticalAlignment &&
        other.widget == widget &&
        other.width == width;
  }

  @override
  int get hashCode {
    final List<Object?> values = <Object?>[
      angle,
      radius,
      height,
      horizontalAlignment,
      verticalAlignment,
      widget,
      width,
    ];
    return Object.hashAll(values);
  }
}

class ConnectorLineSettings {
  const ConnectorLineSettings({
    this.length,
    double? width,
    ConnectorType? type,
    this.color,
  })  : width = width ?? 1.0,
        type = type ?? ConnectorType.line;

  final String? length;

  final double width;

  final Color? color;

  final ConnectorType type;

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) {
      return true;
    }
    if (other.runtimeType != runtimeType) {
      return false;
    }

    return other is ConnectorLineSettings &&
        other.length == length &&
        other.width == width &&
        other.color == color &&
        other.type == type;
  }

  @override
  int get hashCode {
    final List<Object?> values = <Object?>[length, width, color, type];
    return Object.hashAll(values);
  }
}
